package org.fun.kafkademo.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 用户事件数据模型
 */
public class UserEvent {
    
    private String userId;
    private String eventType;
    private String eventData;
    private String sessionId;
    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime timestamp;
    
    private String ipAddress;
    private String userAgent;
    
    public UserEvent() {}
    
    public UserEvent(String userId, String eventType, String eventData, String sessionId, 
                     LocalDateTime timestamp, String ipAddress, String userAgent) {
        this.userId = userId;
        this.eventType = eventType;
        this.eventData = eventData;
        this.sessionId = sessionId;
        this.timestamp = timestamp;
        this.ipAddress = ipAddress;
        this.userAgent = userAgent;
    }
    
    // Getters and Setters
    public String getUserId() {
        return userId;
    }
    
    public void setUserId(String userId) {
        this.userId = userId;
    }
    
    public String getEventType() {
        return eventType;
    }
    
    public void setEventType(String eventType) {
        this.eventType = eventType;
    }
    
    public String getEventData() {
        return eventData;
    }
    
    public void setEventData(String eventData) {
        this.eventData = eventData;
    }
    
    public String getSessionId() {
        return sessionId;
    }
    
    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }
    
    public LocalDateTime getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(LocalDateTime timestamp) {
        this.timestamp = timestamp;
    }
    
    public String getIpAddress() {
        return ipAddress;
    }
    
    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }
    
    public String getUserAgent() {
        return userAgent;
    }
    
    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserEvent userEvent = (UserEvent) o;
        return Objects.equals(userId, userEvent.userId) &&
               Objects.equals(eventType, userEvent.eventType) &&
               Objects.equals(eventData, userEvent.eventData) &&
               Objects.equals(sessionId, userEvent.sessionId) &&
               Objects.equals(timestamp, userEvent.timestamp) &&
               Objects.equals(ipAddress, userEvent.ipAddress) &&
               Objects.equals(userAgent, userEvent.userAgent);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(userId, eventType, eventData, sessionId, timestamp, ipAddress, userAgent);
    }
    
    @Override
    public String toString() {
        return "UserEvent{" +
               "userId='" + userId + '\'' +
               ", eventType='" + eventType + '\'' +
               ", eventData='" + eventData + '\'' +
               ", sessionId='" + sessionId + '\'' +
               ", timestamp=" + timestamp +
               ", ipAddress='" + ipAddress + '\'' +
               ", userAgent='" + userAgent + '\'' +
               '}';
    }
}
